//
// Created by wxd on 2025/9/2.
// 引擎的全局几何管理器
//

#pragma once

#ifndef GEOMETRYMANAGER_H
#define GEOMETRYMANAGER_H

#include <unordered_map>
#include <string>
#include <mutex>
#include <memory>

#include "../glFramework/geo/BaseGeometry.h"


class GeometryManager {
public:
    GeometryManager(const GeometryManager&) = delete;
    GeometryManager& operator=(const GeometryManager&) = delete;

    static GeometryManager& getInstance() {
        static GeometryManager instance;
        return instance;
    }

    std::string addGeo(const BaseGeometry& geo);
    BaseGeometry* getGeo(const std::string& geoId);
    bool removeGeo(const std::string& geoId);
    bool contain(const std::string& geoId);
    void clear();

private:
    GeometryManager() = default;
    ~GeometryManager() = default;

    std::mutex m_lock {};
    std::unordered_map<std::string, std::unique_ptr<BaseGeometry>> m_GeoMap {};
};

#endif //GEOMETRYMANAGER_H